Dynomotion

Group: DynoMotion Message: 1741 From: bradodarb Date: 8/28/2011
Subject: S and M codes....
Hello,

With respect to the Interpreter; I would like to implement the capability to map S codes and M codes to either C programs on/off the board and also python scripts.

How is this normally implemented? Do I just intercept in the status update callback?

Thank you,

Brad Murry
Group: DynoMotion Message: 1742 From: Tom Kerekes Date: 8/29/2011
Subject: Re: S and M codes....
Hi Brad,
 
There is already a mechanism to map M and S codes to invoke KFLOP User C Programs or Windows Programs (as a separate Process).
 
 
It isn't really a User Friendly interface but basically there is an array of MCODE_ACTIONs:
 
// This structure defines the action and
// parameters for a particular MCode Action
typedef
struct
{
int Action;
double dParams[MAX_MCODE_DOUBLE_PARAMS];
char String[256];
} MCODE_ACTION;
 
 
You must fill in this array to define what to do for each M code, S Code, or User Button.
 
 
 The currently supported "Actions" are defined as:
 
// Misc Commands (M Code) within GCode are normally used
// for spindle on/off and such. In general any M Code
// may be mapped to various KMotion "Actions" such as
//
enum
{
M_Action_None = 0,
// do nothing
M_Action_Setbit = 1,
// Set a bit high or low
M_Action_SetTwoBits = 2,
// Set two bits either high or low
M_Action_DAC = 3,
// output a value to a DAC
M_Action_Program = 4,
// run a KMotion User C program
M_Action_Program_wait = 5,
// run a KMotion User C program wait til finished
M_Action_Program_wait_sync = 6,
// run a KMotion User C program wait til finished, resync positions
M_Action_Program_PC = 7,
// run a Windows program wait til finished
};
 
 
Each of the "Actions" use the available parameters in different ways. 
 
 
You would need to look at the function:
 
// invoke an MCode action to Set A Bit, Dac, execute a program, etc...
int
CGCodeInterpreter::InvokeAction(int i, BOOL FlushBeforeUnbufferedOperation)
 
 
to determine what happens and what structure members are used for the various actions.
 
 
 
I suppose we could expand this to add an action type to call a python program.  Or just do something differently in the "Execute Windows Program" if we detect the string is a filename with a python extension.
 
 
HTH
TK
 

--- On Sun, 8/28/11, bradodarb <bradodarb@...> wrote:

From: bradodarb <bradodarb@...>
Subject: [DynoMotion] S and M codes....
To: DynoMotion@yahoogroups.com
Date: Sunday, August 28, 2011, 3:28 PM

 
Hello,

With respect to the Interpreter; I would like to implement the capability to map S codes and M codes to either C programs on/off the board and also python scripts.

How is this normally implemented? Do I just intercept in the status update callback?

Thank you,

Brad Murry

Group: DynoMotion Message: 1749 From: bradodarb Date: 8/29/2011
Subject: Re: S and M codes....
Hello Tom,

This is great, I should be able to implement the action generation very easily with this information.

Thanks

_____________________________________________________________


What do you think about adding a callback like you did for the (USR,script) scenario?

If this is a good route, it would be nice to have the triple actions like the c program calls do:

1) Fire callback

2) Fire callback and wait for complete; then resume

3) Fire callback and wait for complete; then resync; then resume.



Thanks again,
Brad Murry

--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
>
>
>
>
>
> Hi Brad,
>  
> There is already a mechanism to map M and S codes to invoke KFLOP User C Programs or Windows Programs (as a separate Process).
>  
>  
> It isn't really a User Friendly interface but basically there is an array of MCODE_ACTIONs:
>  
> // This structure defines the action and
> // parameters for a particular MCode Action
> typedef struct
> {
> int Action;
> double dParams[MAX_MCODE_DOUBLE_PARAMS];
> char String[256];
> } MCODE_ACTION;
>  
>  
> You must fill in this array to define what to do for each M code, S Code, or User Button.
>  
>  
>  The currently supported "Actions" are defined as:
>  
> // Misc Commands (M Code) within GCode are normally used
> // for spindle on/off and such. In general any M Code
> // may be mapped to various KMotion "Actions" such as
> //
> enum {
> M_Action_None = 0, // do nothing
> M_Action_Setbit = 1, // Set a bit high or low
> M_Action_SetTwoBits = 2, // Set two bits either high or low
> M_Action_DAC = 3, // output a value to a DAC
> M_Action_Program = 4, // run a KMotion User C program
> M_Action_Program_wait = 5, // run a KMotion User C program wait til finished
> M_Action_Program_wait_sync = 6, // run a KMotion User C program wait til finished, resync positions
> M_Action_Program_PC = 7, // run a Windows program wait til finished
> };
>  
>  
> Each of the "Actions" use the available parameters in different ways. 
>  
>  
> You would need to look at the function:
>  
> // invoke an MCode action to Set A Bit, Dac, execute a program, etc...
> int CGCodeInterpreter::InvokeAction(int i, BOOL FlushBeforeUnbufferedOperation)
>  
>  
> to determine what happens and what structure members are used for the various actions.
>  
>  
>  
> I suppose we could expand this to add an action type to call a python program.  Or just do something differently in the "Execute Windows Program" if we detect the string is a filename with a python extension.
>  
>  
> HTH
> TK
>  
>
> --- On Sun, 8/28/11, bradodarb <bradodarb@...> wrote:
>
>
> From: bradodarb <bradodarb@...>
> Subject: [DynoMotion] S and M codes....
> To: DynoMotion@yahoogroups.com
> Date: Sunday, August 28, 2011, 3:28 PM
>
>
>  
>
>
>
> Hello,
>
> With respect to the Interpreter; I would like to implement the capability to map S codes and M codes to either C programs on/off the board and also python scripts.
>
> How is this normally implemented? Do I just intercept in the status update callback?
>
> Thank you,
>
> Brad Murry
>
Group: DynoMotion Message: 1751 From: Tom Kerekes Date: 8/29/2011
Subject: Re: S and M codes....
Hi Brad,
 
Sounds reasonable to me.  Except I think we had the same discussion as with the GCode Call back that the Interpreter thread is making the callback so it would be up to you to wait until your own action is complete before returning or to launch another thread to do your action and return immediately.  Unlike launching a KFLOP program which is always a truly parallel process.  I'm also inclined to just always re-sync after the callback returns.
 
Regards
TK

--- On Mon, 8/29/11, bradodarb <bradodarb@...> wrote:

From: bradodarb <bradodarb@...>
Subject: [DynoMotion] Re: S and M codes....
To: DynoMotion@yahoogroups.com
Date: Monday, August 29, 2011, 6:13 PM

 
Hello Tom,

This is great, I should be able to implement the action generation very easily with this information.

Thanks

__________________________________________________________

What do you think about adding a callback like you did for the (USR,script) scenario?

If this is a good route, it would be nice to have the triple actions like the c program calls do:

1) Fire callback

2) Fire callback and wait for complete; then resume

3) Fire callback and wait for complete; then resync; then resume.

Thanks again,
Brad Murry

--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
>
>
>
>
>
> Hi Brad,
>  
> There is already a mechanism to map M and S codes to invoke KFLOP User C Programs or Windows Programs (as a separate Process).
>  
>  
> It isn't really a User Friendly interface but basically there is an array of MCODE_ACTIONs:
>  
> // This structure defines the action and
> // parameters for a particular MCode Action
> typedef struct
> {
> int Action;
> double dParams[MAX_MCODE_DOUBLE_PARAMS];
> char String[256];
> } MCODE_ACTION;
>  
>  
> You must fill in this array to define what to do for each M code, S Code, or User Button.
>  
>  
>  The currently supported "Actions" are defined as:
>  
> // Misc Commands (M Code) within GCode are normally used
> // for spindle on/off and such. In general any M Code
> // may be mapped to various KMotion "Actions" such as
> //
> enum {
> M_Action_None = 0, // do nothing
> M_Action_Setbit = 1, // Set a bit high or low
> M_Action_SetTwoBits = 2, // Set two bits either high or low
> M_Action_DAC = 3, // output a value to a DAC
> M_Action_Program = 4, // run a KMotion User C program
> M_Action_Program_wait = 5, // run a KMotion User C program wait til finished
> M_Action_Program_wait_sync = 6, // run a KMotion User C program wait til finished, resync positions
> M_Action_Program_PC = 7, // run a Windows program wait til finished
> };
>  
>  
> Each of the "Actions" use the available parameters in different ways. 
>  
>  
> You would need to look at the function:
>  
> // invoke an MCode action to Set A Bit, Dac, execute a program, etc...
> int CGCodeInterpreter::InvokeAction(int i, BOOL FlushBeforeUnbufferedOperation)
>  
>  
> to determine what happens and what structure members are used for the various actions.
>  
>  
>  
> I suppose we could expand this to add an action type to call a python program.  Or just do something differently in the "Execute Windows Program" if we detect the string is a filename with a python extension.
>  
>  
> HTH
> TK
>  
>
> --- On Sun, 8/28/11, bradodarb <bradodarb@...> wrote:
>
>
> From: bradodarb <bradodarb@...>
> Subject: [DynoMotion] S and M codes....
> To: DynoMotion@yahoogroups.com
> Date: Sunday, August 28, 2011, 3:28 PM
>
>
>  
>
>
>
> Hello,
>
> With respect to the Interpreter; I would like to implement the capability to map S codes and M codes to either C programs on/off the board and also python scripts.
>
> How is this normally implemented? Do I just intercept in the status update callback?
>
> Thank you,
>
> Brad Murry
>

Group: DynoMotion Message: 1754 From: bradodarb Date: 8/29/2011
Subject: Re: S and M codes....
Hello Tom,

And as before you are right on the simplification....

Thanks
Brad Murry


--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> Hi Brad,
>  
> Sounds reasonable to me.  Except I think we had the same discussion as with the GCode Call back that the Interpreter thread is making the callback so it would be up to you to wait until your own action is complete before returning or to launch another thread to do your action and return immediately.  Unlike launching a KFLOP program which is always a truly parallel process.  I'm also inclined to just always re-sync after the callback returns.
>  
> Regards
> TK
>
> --- On Mon, 8/29/11, bradodarb <bradodarb@...> wrote:
>
>
> From: bradodarb <bradodarb@...>
> Subject: [DynoMotion] Re: S and M codes....
> To: DynoMotion@yahoogroups.com
> Date: Monday, August 29, 2011, 6:13 PM
>
>
>  
>
>
>
> Hello Tom,
>
> This is great, I should be able to implement the action generation very easily with this information.
>
> Thanks
>
> __________________________________________________________
>
> What do you think about adding a callback like you did for the (USR,script) scenario?
>
> If this is a good route, it would be nice to have the triple actions like the c program calls do:
>
> 1) Fire callback
>
> 2) Fire callback and wait for complete; then resume
>
> 3) Fire callback and wait for complete; then resync; then resume.
>
> Thanks again,
> Brad Murry
>
> --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> >
> >
> >
> >
> >
> >
> > Hi Brad,
> >  
> > There is already a mechanism to map M and S codes to invoke KFLOP User C Programs or Windows Programs (as a separate Process).
> >  
> >  
> > It isn't really a User Friendly interface but basically there is an array of MCODE_ACTIONs:
> >  
> > // This structure defines the action and
> > // parameters for a particular MCode Action
> > typedef struct
> > {
> > int Action;
> > double dParams[MAX_MCODE_DOUBLE_PARAMS];
> > char String[256];
> > } MCODE_ACTION;
> >  
> >  
> > You must fill in this array to define what to do for each M code, S Code, or User Button.
> >  
> >  
> >  The currently supported "Actions" are defined as:
> >  
> > // Misc Commands (M Code) within GCode are normally used
> > // for spindle on/off and such. In general any M Code
> > // may be mapped to various KMotion "Actions" such as
> > //
> > enum {
> > M_Action_None = 0, // do nothing
> > M_Action_Setbit = 1, // Set a bit high or low
> > M_Action_SetTwoBits = 2, // Set two bits either high or low
> > M_Action_DAC = 3, // output a value to a DAC
> > M_Action_Program = 4, // run a KMotion User C program
> > M_Action_Program_wait = 5, // run a KMotion User C program wait til finished
> > M_Action_Program_wait_sync = 6, // run a KMotion User C program wait til finished, resync positions
> > M_Action_Program_PC = 7, // run a Windows program wait til finished
> > };
> >  
> >  
> > Each of the "Actions" use the available parameters in different ways. 
> >  
> >  
> > You would need to look at the function:
> >  
> > // invoke an MCode action to Set A Bit, Dac, execute a program, etc...
> > int CGCodeInterpreter::InvokeAction(int i, BOOL FlushBeforeUnbufferedOperation)
> >  
> >  
> > to determine what happens and what structure members are used for the various actions.
> >  
> >  
> >  
> > I suppose we could expand this to add an action type to call a python program.  Or just do something differently in the "Execute Windows Program" if we detect the string is a filename with a python extension.
> >  
> >  
> > HTH
> > TK
> >  
> >
> > --- On Sun, 8/28/11, bradodarb <bradodarb@> wrote:
> >
> >
> > From: bradodarb <bradodarb@>
> > Subject: [DynoMotion] S and M codes....
> > To: DynoMotion@yahoogroups.com
> > Date: Sunday, August 28, 2011, 3:28 PM
> >
> >
> >  
> >
> >
> >
> > Hello,
> >
> > With respect to the Interpreter; I would like to implement the capability to map S codes and M codes to either C programs on/off the board and also python scripts.
> >
> > How is this normally implemented? Do I just intercept in the status update callback?
> >
> > Thank you,
> >
> > Brad Murry
> >
>